<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" import="java.util.Date"%>
<%
	String path = request.getContextPath();
	// 获得本项目的地址(例如: http://localhost:8080/MyApp/)赋值给basePath变量 
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	// 将 "项目路径basePath" 放入pageContext中，待以后用EL表达式读出。 
	pageContext.setAttribute("basePath", basePath);
	request.setAttribute("time", new Date().getTime());
%>
<%@include file="../common/jspcommon.jsp"%>
<script type="text/javascript">
	
	$(function() {
		//搜索结果页分页
		$("#pager").pager({
			pagenumber : '${pageModel.currentPage}',
			pagecount : '${pageModel.totalPage}',
			buttonClickCallback : function(page) {
				searchDoing(page,"${systemTag}");
			}
		});
		
		$("#parent${time}").ligerComboBox({
			width : 215,
			selectBoxWidth : 215,
			selectBoxHeight : 180,
			valueField : 'mark',
			textField : 'text',
			treeLeafOnly : false,
			tree : {
				checkbox : false,
				btnClickToToggleOnly : false,
				url : '/misc/cms/channelTree.htm'
			}
		});

	});

	//全选
	function allSelect(self) {
		if ($("#search_result").find("input:checkbox").attr("checked") == "checked") {
			$("#search_result").find("input:checkbox").attr("checked", false);
			$(self).html("全选");
		} else {
			$("#search_result").find("input:checkbox").attr("checked", true);
			$(self).html("全不选");
		}
	}
	//屏蔽
	function allShield(enabled) {
		var idList = "('";
		$("input:checkbox").each(function(i) {
			if ($(this).attr("checked") == "checked") {
				idList += $(this).attr("value") + "','";
			}
		})
		if (idList.substring(idList.length - 2, idList.length) == ",'") {
			idList = idList.substring(0, idList.length - 3);
		}
		idList += "')";
		$.post("/misc/audit/shieldDoing.htm", {
			idList : idList,
			enabled : enabled
		}, function(data) {
			searchDoing("${page}","${systemTag}");
		});
	}
	//删除
	function allDelete() {
		var idList = "('";
		$("input:checkbox").each(function(i) {
			if ($(this).attr("checked") == "checked") {
				idList += $(this).attr("value") + "','";
			}
		})
		if (idList.substring(idList.length - 2, idList.length) == ",'") {
			idList = idList.substring(0, idList.length - 3);
		}
		idList += "')";
		$.post("/misc/audit/deleteDoing.htm", {
			idList : idList
		}, function(data) {
			searchDoing("${page}","${systemTag}");
		});
	}
	
	//设置返利
	function szfl(self,id){
		var gcr = $(self).next();
		var beginDate = $(gcr).next();
		var endDate = $(beginDate).next();
		var beginDateValue = $(beginDate).val();
		var endDateValue = $(endDate).val();
		if ($(beginDate).css("display")=="none") {
			$(beginDate).val("");
			$(beginDate).show();
		}
		if ($(endDate).css("display")=="none") {
			$(endDate).val("");
			$(endDate).show();
		}
		if($(gcr).css("display")=="none"){
			$(gcr).val("");
			$(gcr).show();
			$(self).text("保存");
		}else{
			var value = $.trim($(gcr).val());
			//var number = /^-?\d+$/;
			var number = /^0\.\d\d$/;
			if(!number.test(value)){
				alert("亲，【返利比率】设置格式不对！");
				return;
			}
			if(null == beginDateValue || ""==beginDateValue){
				alert("亲，请设置【返利开始时间】！");
				return;
			}
			if(null == endDateValue || ""==endDateValue){
				alert("亲，请设置【返利结束时间】！");
				return;
			}
			$.post("/misc/audit/updategcr.htm",{
				doingProductId : id,
				guoguojieCommissionRate : value,
				beginTime : beginDateValue,
				endTime : endDateValue
			},function(data){
				if(data == "success"){
					alert("亲，限时返利商品发布成功！");
					$(text).hide();
					$(beginDate).hide();
					$(endDate).hide();
					$(self).text("设置返利");
				}else if(data == "exist"){
					alert("亲，该商品在【"+beginDateValue+"】到【"+endDateValue+"】这个时段内已经设置过返利了，不能重复设置！");
				}else{
					alert("亲，系统有点抽经，请稍候重试！");
				}
			});
		}
	}
	
</script>
<table border="1" width="100%">
	<tr>
		<th colspan="2">编号</th>
		<th>昵称</th>
		<th>商品</th>
		<th>图片</th>
		<th>内容</th>
		<th>回复数</th>
		<th>发布时间</th>
		<th>IP</th>
		<th>状态</th>
	</tr>
	<c:if test="${fn:length(pageModel.list)<=0 }">
		<tr>
			<td colspan="12">没有符合您的搜索结果</td>
		</tr>
	</c:if>
	<c:forEach items="${pageModel.list }" var="doing" varStatus="v">
		<tr>
			<td>
				<input type="checkbox" value="${doing.identifier }" />
				<span style="display: none;" id="tblName" >doing</span>
				<span style="display: none;" id="tblIdentifier" >${doing.identifier }</span>
				<span style="display: none;" id="systemTag" >${doing.systemTag }</span>
				<span style="display: none;" id="title" >${doing.doingProductList[0].name }</span>
				<span style="display: none;" id="description" >${doing.replaceContent }</span>
				<span style="display: none;" id="nickname" >${doing.memberName }</span>
				<span style="display: none;" id="doorplate" >${doing.owner }</span>
				<span style="display: none;" id="picture" ><c:if test="${fn:length(doing.doingPictureList)>0 }">${doing.doingPictureList[0].imageServer }${doing.doingPictureList[0].picUrl }</c:if></span>
				<span style="display: none;" id="videoPic" >${doing.videoPic}</span>
				<span style="display: none;" id="productPic" ><c:if test="${fn:length(doing.doingProductList)>0 }">${doing.doingProductList[0].imageServer}${doing.doingProductList[0].picThumb }_468xXXX.jpg</c:if></span>
				<span style="display: none;" id="pictorialPic"><c:if test="${fn:length(doing.picList6)>0 }">${doing.picList6[0] }_200xXXX.jpg</c:if></span>
			</td>
			<td>${v.index+1 }</td>
			<td>
				<c:choose>
					<c:when test="${type == 'picRoot' }">
						<a href="<%=basePath%>picdt.htm?id=${doing.identifier }&family=${doing.owner }" target="_blank">${doing.memberName }</a>					
					</c:when>
					<c:otherwise>
						<a href="<%=basePath%>family?id=${doing.owner }" target="_blank">${doing.memberName }</a>					
					</c:otherwise>
				</c:choose>
			</td>
			<td>
				<c:if test="${doing.doingProductList!=null && fn:length(doing.doingProductList)>0 }">
					<c:forEach items="${doing.doingProductList }" var="product">
						<span>
							<img src="${product.imageServer }${product.picThumb }_468xXXX.jpg" width="80" height="80"
								onmouseover="pictureTipShow(this)" onmouseout="pictureTipHide()" />
							${product.price }/${product.commission }
							<button onclick="szfl(this,'${product.identifier}')">设置返利</button>
							<select style="display: none;">
								<option value="0.01">1%</option>
								<option value="0.02">2%</option>
								<option value="0.03">3%</option>
								<option value="0.04">4%</option>
								<option value="0.05">5%</option>
								<option value="0.06">6%</option>
								<option value="0.07">7%</option>
								<option value="0.08">8%</option>
								<option value="0.09">9%</option>
								<option value="0.10">10%</option>
								<option value="0.11">11%</option>
								<option value="0.12">12%</option>
								<option value="0.13">13%</option>
								<option value="0.14">14%</option>
								<option value="0.15">15%</option>
								<option value="0.16">16%</option>
								<option value="0.17">17%</option>
								<option value="0.18">18%</option>
								<option value="0.19">19%</option>
								<option value="0.20">20%</option>
								<option value="0.21">21%</option>
								<option value="0.22">22%</option>
								<option value="0.23">23%</option>
								<option value="0.24">24%</option>
								<option value="0.25">25%</option>
								<option value="0.26">26%</option>
								<option value="0.27">27%</option>
								<option value="0.28">28%</option>
								<option value="0.29">29%</option>
								<option value="0.30">30%</option>
								<option value="0.31">31%</option>
								<option value="0.32">32%</option>
								<option value="0.33">33%</option>
								<option value="0.34">34%</option>
								<option value="0.35">35%</option>
								<option value="0.36">36%</option>
								<option value="0.37">37%</option>
								<option value="0.38">38%</option>
								<option value="0.39">39%</option>
								<option value="0.40">40%</option>
								<option value="0.41">41%</option>
								<option value="0.42">42%</option>
								<option value="0.43">43%</option>
								<option value="0.44">44%</option>
								<option value="0.45">45%</option>
								<option value="0.46">46%</option>
								<option value="0.47">47%</option>
								<option value="0.48">48%</option>
								<option value="0.49">49%</option>
								<option value="0.50">50%</option>
								<option value="0.51">51%</option>
								<option value="0.52">52%</option>
								<option value="0.53">53%</option>
								<option value="0.54">54%</option>
								<option value="0.55">55%</option>
								<option value="0.56">56%</option>
								<option value="0.57">57%</option>
								<option value="0.58">58%</option>
								<option value="0.59">59%</option>
								<option value="0.60">60%</option>
								<option value="0.61">61%</option>
								<option value="0.62">62%</option>
								<option value="0.63">63%</option>
								<option value="0.64">64%</option>
								<option value="0.65">65%</option>
								<option value="0.66">66%</option>
								<option value="0.67">67%</option>
								<option value="0.68">68%</option>
								<option value="0.69">69%</option>
								<option value="0.70">70%</option>
								<option value="0.71">71%</option>
								<option value="0.72">72%</option>
								<option value="0.73">73%</option>
								<option value="0.74">74%</option>
								<option value="0.75">75%</option>
								<option value="0.76">76%</option>
								<option value="0.77">77%</option>
								<option value="0.78">78%</option>
								<option value="0.79">79%</option>
								<option value="0.80">80%</option>
								<option value="0.81">81%</option>
								<option value="0.82">82%</option>
								<option value="0.83">83%</option>
								<option value="0.84">84%</option>
								<option value="0.85">85%</option>
								<option value="0.86">86%</option>
								<option value="0.87">87%</option>
								<option value="0.88">88%</option>
								<option value="0.89">89%</option>
								<option value="0.90">90%</option>
								<option value="0.91">91%</option>
								<option value="0.92">92%</option>
								<option value="0.93">93%</option>
								<option value="0.94">94%</option>
								<option value="0.95">95%</option>
								<option value="0.96">96%</option>
								<option value="0.97">97%</option>
								<option value="0.98">98%</option>
								<option value="0.99">99%</option>
								<option value="1.00">100%</option>
							</select>
							<input type="text" id="beginDate${doing.identifier}" readonly="readonly" onclick="WdatePicker({el:'beginDate${doing.identifier}',dateFmt:'yyyy-MM-dd HH:mm:ss',readOnly:true});" style="display: none;"/>
							<input type="text" id="endDate${doing.identifier}" readonly="readonly" onclick="WdatePicker({el:'endDate${doing.identifier}',dateFmt:'yyyy-MM-dd HH:mm:ss',readOnly:true});" style="display: none;"/>
							<img id="yuanTu" style="display: none;" src="${product.imageServer }${product.picThumb }_468xXXX.jpg">
						</span>
					</c:forEach>
				</c:if>
			</td>
			<td>
				<c:if test="${doing.doingPictureList!=null && fn:length(doing.doingPictureList)>0 }">
					<c:forEach items="${doing.doingPictureList }" var="picture">
						<span>
						<a href="/misc/audit/doingDetail.htm?imageServer=${picture.imageServer }&picUrl=${picture.picUrl}" target="_blank">
							<img src="${picture.imageServer }${picture.picUrl }" width="80" height="80"
								onmouseover="pictureTipShow(this)" onmouseout="pictureTipHide()" />
							<img id="yuanTu" style="display: none;" src="${picture.imageServer }${picture.picUrl}">
						</a>
						</span>
					</c:forEach>
				</c:if>
				<c:if test="${type == 'picRoot' }">
					<img src="${doing.picList6[0] }_200xXXX.jpg">
				</c:if>
			</td>
			<td>${doing.replaceContent }</td>
			<td>${doing.replyAmount }</td>
			<td><fmt:formatDate value="${doing.gmtCreated }" pattern="yyyy-MM-dd HH:mm:ss" /></td>
			<td>${doing.postIp }</td>
			<td><c:if test="${doing.enabled==true }">正常</c:if> <c:if
					test="${doing.enabled==false }">已屏蔽</c:if></td>
		</tr>
	</c:forEach>
	<tr>
		<td colspan="12">
			<a href="javascript:void(0);" onclick="allSelect(this)">全选</a>&nbsp;&nbsp;&nbsp;
			<!-- <a href="javascript:allShield('false')">屏蔽</a>&nbsp;&nbsp;&nbsp;
			<a href="javascript:allShield('true')">恢复</a>&nbsp;&nbsp;&nbsp;
			<a href="javascript:allDelete()">删除</a>&nbsp;&nbsp;&nbsp; -->
		</td>
	</tr>
	<tr>
		<td colspan="12">
		<input type="text" id="parent${time}"/><span id="que_ren_tui_song" style="color: red; cursor: pointer;" onclick="queRenTuiSong()">确定推送</span>
		<input type="hidden" id="parent_val" value="parent${time}">
		</td>
	</tr>
	<c:if test="${pageModel.totalRecord > 1}">
		<tr>
			<td colspan="12"><div class="h_page" id="pager"></div>
			</td>
		</tr>
	</c:if>
</table>
